package gui;

import javax.swing.InputVerifier;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class VNuevoTema extends JPanel {
	private JTextField textField;
	private JButton btnAadir;

	/**
	 * Create the panel.
	 */
	public VNuevoTema() {
		setBorder(new LineBorder(new Color(0, 0, 0)));
		
		
		
		textField = new JTextField();
	    
		textField.addKeyListener(new KeyAdapter() {
			@Override
			public void keyReleased(KeyEvent e) {
				if(textField.getText().equals(""))
					btnAadir.setEnabled(false);
					else if(!btnAadir.isEnabled())
						btnAadir.setEnabled(true);
				if(e.getKeyCode()==KeyEvent.VK_ENTER && btnAadir.isEnabled())
					btnAadir.doClick();
			}
		});
	    
		add(textField);
		textField.setColumns(10);
		
		btnAadir = new JButton("A\u00F1adir");
		btnAadir.setEnabled(false);
		add(btnAadir);

	}

	public JButton getButton(){
		return btnAadir;
	}
	
	public String getText(){
		return textField.getText();
	}
	
	public void setText(String text){
		textField.setText(text);
	}

}
